package com.bugpool.leilema.order.controller;


import com.bugpool.leilema.order.dto.ConvertOrderAddVo2OrderAddDto;
import com.bugpool.leilema.order.dto.OrderAddDto;
import com.bugpool.leilema.order.service.OrderMasterService;
import com.bugpool.leilema.order.vo.OrderAddVo;
import com.bugpool.leilema.order.vo.OrderQueryVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author bugpool
 * @since 2020-04-18
 */
@RestController
@RequestMapping("/order/order-master")
public class OrderMasterController {

    @Autowired
    OrderMasterService orderMasterService;

    @PostMapping("/create")
    public int create(OrderAddVo orderAddVo) {
        OrderAddDto orderAddDto = ConvertOrderAddVo2OrderAddDto.convert(orderAddVo);
        return orderMasterService.createOrder(orderAddDto);
    }

    @PostMapping("/cancle")
    public boolean cancle(int orderId) {
        return orderMasterService.cancel(orderId);
    }

    @PostMapping("/findById")
    public OrderQueryVo findById(int orderId) {
        return orderMasterService.findOrderById(orderId);
    }

}
